home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 119_01.zip / DEMO.C < prev    next >
Text File  |  1993-06-16  |  8KB  |  229 lines

  1. /* DEMO.C - Set up the key bindings for Mince, Demo mode
  2.    Contributed to the AUG by Mark of the Unicorn 07/20/81 
  3.  
  4. The seller of this software hereby disclaims any and all
  5. guarantees and warranties, both express and implied.  No
  6. liability of any form shall be assumed by the seller, nor shall
  7. direct, consequential, or other damages be assumed by the seller.
  8. Any user of this software uses it at his or her own risk.
  9.  
  10. Due to the ill-defined nature of "fitness for purpose" or similar
  11. types of guarantees for this type of product, no fitness for any
  12. purpose whatsoever is claimed or implied.
  13.  
  14. The physical medium upon which the software is supplied is
  15. guaranteed for one year against any physical defect.  If it
  16. should fail, return it to the seller, and a new physical medium
  17. with a copy of the purchased software shall be sent.
  18.  
  19. The seller reserve the right to make changes, additions, and
  20. improvements to the software at any time; no guarantee is made
  21. that future versions of the software will be compatible with any
  22. other version.
  23.  
  24. The parts of this disclaimer are severable and fault found in any
  25. one part does not invalidate any other parts.
  26.  
  27.     Copyright (c) 1981 by Mark of the Unicorn
  28.     Created for Version 2.3  10/4/80  JTL
  29.     Updated to version three  1/7/81  JTL
  30.  
  31.     This file contains the function table initializers and mode set up
  32. functions */
  33.  
  34. #include "mince.gbl"
  35.  
  36. finit1()            /* initialize the control and self insert key bindings */
  37. {
  38.     int cnt;
  39.     int MInsert(), MSetMrk(), MBegLin(), MPrevChar();
  40.     int MNotImpl(), MDelChar(), MEndLin(), MNextChar();
  41.     int MAbort(), MDelLin(), NewDsp(), MNewLin();
  42.     int MNextLin(), MOpenLin(), MPrevLin(), MQuote();
  43.     int MRSearch(), MSearch(), MSwapChar(), MArg();
  44.     int MNextPage(), MDelRgn(), MCtrlX(), MYank();
  45.     int MMeta(), MDelIndent(), MRDelChar(), MIndent();
  46.  
  47.  
  48.     for (cnt=0; cnt<128; ++cnt) functs[cnt] = &MInsert;
  49.     TKbChk();
  50.     functs[0] = &MSetMrk;        /* C-@ */
  51.     functs[1] = &MBegLin;        /* C-A */
  52.     functs[2] = &MPrevChar;        /* C-B */
  53.     functs[3] = &MNotImpl;        /* C-C */
  54.     functs[4] = &MDelChar;        /* C-D */
  55.     functs[5] = &MEndLin;        /* C-E */
  56.     functs[6] = &MNextChar;        /* C-F */
  57.     functs[7] = &MAbort;        /* C-G */
  58.     functs[8] = &MRDelChar;        /* C-H */
  59.                             /* C-I */
  60.     functs[10] = &MIndent;        /* C-J */
  61.     functs[11] = &MDelLin;        /* C-K */
  62.     functs[12] = &NewDsp;        /* C-L */
  63.     functs[13] = &MNewLin;        /* C-M */
  64.     functs[14] = &MNextLin;        /* C-N */
  65.     functs[15] = &MOpenLin;        /* C-O */
  66.     functs[16] = &MPrevLin;        /* C-P */
  67.     functs[17] = &MQuote;        /* C-Q */
  68.     functs[18] = &MRSearch;        /* C-R */
  69.     functs[19] = &MSearch;        /* C-S */
  70.     functs[20] = &MSwapChar;        /* C-T */
  71.     functs[21] = &MArg;            /* C-U */
  72.     functs[22] = &MNextPage;        /* C-V */
  73.     functs[23] = &MDelRgn;        /* C-W */
  74.     functs[24] = &MCtrlX;        /* C-X */
  75.     functs[25] = &MYank;        /* C-Y */
  76.     functs[26] = &MNotImpl;        /* C-Z */
  77.     functs[ESC] = &MMeta;        /* ESC */
  78.     functs[28] = &MDelIndent;    /* C-\ */
  79.     functs[29] = &MNotImpl;        /* C-] */
  80.     functs[30] = &MNotImpl;        /* C-^ */
  81.     functs[31] = &MNotImpl;        /* C-_ */
  82.     functs[DEL] = &MRDelChar;    /* DEL */
  83.     }
  84.  
  85. finit2()            /* set up the Meta key bindings */
  86. {
  87.     int cnt;
  88.     int MNotImpl(), MAbort(), MDelELin(), MQryRplc();
  89.     int MMakeDel(), MToStart(), MToEnd(), MBSent();
  90.     int BWord(), MCapWord(), MDelWord(), MFSent();
  91.     int FWord(), MMrkPara(), MDelSent(), MLowWord();
  92.     int MFillPara(), MReplace(), MCntrLine(), MUpWord();
  93.     int MPrevPage(), MCopyRgn(), MBPara(), MDelWhite();
  94.     int MFPara(), MRDelWord(), MSetMrk(), MSwapWord();
  95.  
  96.     for (cnt=128; cnt<256; ++cnt) functs[cnt] = &MNotImpl;
  97.     TKbChk();
  98.     functs[128+7] = &MAbort;                    /* M-C-G */
  99.     functs[128+8] = &MRDelWord;                /* M-C-H */
  100.     functs[128+11] = &MDelELin;                /* M-C-K */
  101.     functs[128+18] = &MQryRplc;                /* M-C-R */
  102.     functs[128+23] = &MMakeDel;                /* M-C-W */
  103.     functs[128+'<'] = &MToStart;                /* M-< */
  104.     functs[128+'>'] = &MToEnd;                /* M-> */
  105.     functs[128+' '] = &MSetMrk;                /* M-  */
  106.     functs[128+'A']=functs[128+'a'] = &MBSent;    /* M-A */
  107.     functs[128+'B']=functs[128+'b'] = &BWord;    /* M-B */
  108.     functs[128+'C']=functs[128+'c'] = &MCapWord;    /* M-C */
  109.     functs[128+'D']=functs[128+'d'] = &MDelWord;    /* M-D */
  110.     functs[128+'E']=functs[128+'e'] = &MFSent;    /* M-E */
  111.     functs[128+'F']=functs[128+'f'] = &FWord;    /* M-F */
  112.     functs[128+'H']=functs[128+'h'] = &MMrkPara;    /* M-H */
  113.     functs[128+'K']=functs[128+'k'] = &MDelSent;    /* M-K */
  114.     functs[128+'L']=functs[128+'l'] = &MLowWord;    /* M-L */
  115.     functs[128+'Q']=functs[128+'q'] = &MFillPara;/* M-Q */
  116.     functs[128+'R']=functs[128+'r'] = &MReplace;    /* M-R */
  117.     functs[128+'S']=functs[128+'s'] = &MCntrLine;/* M-S */
  118.     functs[128+'T']=functs[128+'t'] = &MSwapWord;/* M-T */
  119.     functs[128+'U']=functs[128+'u'] = &MUpWord;    /* M-U */
  120.     functs[128+'V']=functs[128+'v'] = &MPrevPage;/* M-V */
  121.     functs[128+'W']=functs[128+'w'] = &MCopyRgn;    /* M-W */
  122.     functs[128+'['] = &MBPara;                /* M-[ */
  123.     functs[128+'\\'] = &MDelWhite;            /* M-\ */
  124.     functs[128+']'] = &MFPara;                /* M-] */
  125.     functs[128+DEL] = &MRDelWord;                /* M-DEL */
  126.     }
  127.  
  128. finit3()            /* set up the Control-X key bindings */
  129. {
  130.     int cnt;
  131.     int MNotImpl(), MLstBuffs(), MExit(), MFindFile();
  132.     int MAbort(), MSetTabs(), MDelMode(), MFileRead();
  133.     int MSwapMrk(), MSetIndent();
  134.     int MPrintPos(), MSwitchTo(), MKillBuff(), MSetFill();
  135.     int MAddMode(), MOneWind(), MTwoWind(), MSwpWind();
  136.     int MNxtOthrWind(), MPrvOthrWind(), MGrowWind();
  137. #ifdef UNIX
  138.     int MUnix();
  139. #endif
  140.  
  141.     for (cnt=256; cnt<384; ++cnt) functs[cnt] = &MNotImpl;
  142.     TKbChk();
  143.     functs[256+2] = &MLstBuffs;                /* C-X C-B */
  144.     functs[256+3] = &MExit;                    /* C-X C-C */
  145.     functs[256+6] = &MFindFile;                /* C-X C-F */
  146.     functs[256+7] = &MAbort;                    /* C-X C-G */
  147.     functs[256+9] = &MSetTabs;                /* C-X Tab */
  148.     functs[256+13] = &MDelMode;                /* C-X C-M */
  149.     functs[256+18] = &MFileRead;                /* C-X C-R */
  150.     functs[256+22] = &MNxtOthrWind;            /* C-X C-V */
  151.     functs[256+24] = &MSwapMrk;                /* C-X C-X */
  152.     functs[256+26] = &MPrvOthrWind;            /* C-X C-Z */
  153.     functs[256+'.'] = &MSetIndent;            /* C-X . */
  154. #ifdef UNIX
  155.     functs[256+'!'] = &MUnix;                /* C-X ! */
  156. #endif
  157.     functs[256+'='] = &MPrintPos;                /* C-X = */
  158.     functs[256+'1'] = &MOneWind;                /* C-X 1 */
  159.     functs[256+'2'] = &MTwoWind;                /* C-X 2 */
  160.     functs[256+'B']=functs[256+'b'] = &MSwitchTo;/* C-X B */
  161.     functs[256+'K']=functs[256+'k'] = &MKillBuff;/* C-X K */
  162.     functs[256+'F']=functs[256+'f'] = &MSetFill;    /* C-X F */
  163.     functs[256+'M']=functs[256+'m'] = &MAddMode;    /* C-X M */
  164.     functs[256+'O']=functs[256+'o'] = &MSwpWind;    /* C-X O */
  165.     functs[256+'^'] = &MGrowWind;                /* C-X ^ */
  166.     }
  167.  
  168. SetModes()            /* Set the modes according to the bmodes array */
  169. {
  170.     int cnt;
  171.     int MFillChk(), MInsert(), MOverwrite(), MPBegLine();
  172.     int MPBChar(), MPEndLine(), MPFChar(), MPBackSpace();
  173.     int MPNextLine(), MPPrevLine(), MTrimWhite(), MPTab();
  174. #ifdef LARGE
  175.     int MNewLin(), MCIndent(), MSInsert();
  176. #endif
  177.  
  178.     strcpy(&mode,"Demo");
  179.     finit1();                    /* Set up the key bindings */
  180.     finit2();
  181.     finit3();
  182.     for (cnt=MAXMODES-1; cnt>=0; --cnt) {
  183.         switch (buffs[cbuff].bmodes[cnt]) {
  184.  
  185. #ifdef LARGE
  186.         case 'c':
  187.             functs[13] = &MCIndent;
  188.             strcat(&mode,"C ");
  189.             break;
  190.         case 's':
  191.             Rebind(&MInsert,&MSInsert);
  192.             strcat(&mode,"Save ");
  193.             break;
  194. #endif
  195.         case 'f':
  196.             functs[' '] = &MFillChk;
  197.             strcat(&mode,"Fill ");
  198.             break;
  199.         case 'p':
  200.             Rebind(&MInsert,&MOverwrite);
  201.             functs[1] = &MPBegLine;
  202.             functs[2] = &MPBChar;
  203.             functs[5] = &MPEndLine;
  204.             functs[6] = &MPFChar;
  205.             functs[8] = &MPBackSpace;
  206.             functs[9] = &MPTab;
  207.             functs[14] = &MPNextLine;
  208.             functs[16] = &MPPrevLine;
  209.             functs[256+'\\'] = &MTrimWhite;
  210.             strcat(&mode,"Page ");
  211.             break;
  212.             }
  213.         }
  214.     mode[strlen(mode)-1]='\0';
  215.     ModeLine();
  216.     }
  217.  
  218. UInit()                /* Do User Code Initialization */
  219.     /* This function is called once at the very beginning. it may be used
  220.     to do any initialization required for user code */
  221. {
  222.     }
  223.  
  224. /* END OF BINDINGS.C - set up key bindings */
  225. et up the key bindings */
  226.     finit2();
  227.     finit3();
  228.     for (cnt=MAXMODES-1; cnt>=0; --cnt) {
  229.         switch (buffs[c